package com.ehsy.statement;

import com.ehsy.common.ResponseVo;
import com.ehsy.config.ForestConverterConfig;
import com.ehsy.model.UserInfo;
import com.ehsy.service.DataConversionService;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.context.annotation.Import;

import javax.annotation.Resource;

/**
 * @author YanZhen_Li
 * @version 1.0
 * @title A9数据转换
 * @description
 * @create 2024/6/18 14:05
 */
@SpringBootTest
//        (webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT,
//                properties = {"spring.config.location=classpath:global-data-conversion-configuration.yml"})
public class A9数据转换 {
    @Resource
    DataConversionService service;

    /**
     * 序列化请求，我们可以进行断点进行我们的序列化对象调用过程
     */
    @Test
    void test001() {
        UserInfo user = new UserInfo("张三", "18", "男", "上海", "13812341234", "123@qq.com", "123456");
        ResponseVo<UserInfo> test1 = service.test1(user);
        System.out.println(test1);
    }

    /**
     * 反序列化响应体，可以进行断点查看我们反序列化对象的调用过程
     */
    @Test
    void test002() {
        UserInfo user = new UserInfo("张三", "18", "男", "上海", "13812341234", "123@qq.com", "123456");
        ResponseVo<UserInfo> test2 = service.test2(user);
        ResponseVo<UserInfo> test3 = service.test3(user);
        ResponseVo<UserInfo> test4 = service.test4(user);

        System.out.println(test2);
        System.out.println(test3);
        System.out.println(test4);
    }

    /**
     * 全局转换器
     * ! 需要头部环境
     */
    @Test
    void test003(){
        UserInfo user = new UserInfo("张三", "18", "男", "上海", "13812341234", "123@qq.com", "123456");
        ResponseVo<UserInfo> test2 = service.test2(user);
        System.out.println(test2);
    }

    /**
     * springBoot 配置
     * ! 需要放开以下配置类
     * {@link ForestConverterConfig}
     */
    @Test
    void test004(){
        UserInfo user = new UserInfo("张三", "18", "男", "上海", "13812341234", "123@qq.com", "123456");
        ResponseVo<UserInfo> test2 = service.test2(user);
        System.out.println(test2);
    }
}
